﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PBOffice.Models;
using PBOffice.BLL;

public partial class AppraisalManager_AppraisalCheck_ : System.Web.UI.Page
{
    List<ManualSign> list;
    protected void Page_Load(object sender, EventArgs e)
    {
        this.GridView1.Visible = false;
        this.txtDept.Enabled = false;
        this.txtNo.Enabled = false;
        this.txtName.Enabled = false;
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            int num = Convert.ToInt32(e.Row.Cells[2].Text);
            string str = num == 1 ? "签到" : "签退";
            Label la = new Label();
            la.Text = str;
            e.Row.Cells[2].Controls.Add(la);
        }
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        if (CheckEmpty() == true)
        {
            this.GridView1.Visible = true;
            DateTime begin = Convert.ToDateTime(this.txtBeginTime.Text);
            DateTime end = Convert.ToDateTime(this.txtEndTime.Text);
            if (this.cbDept.Checked == true)
            {
                list = new ManualSignManager().GetAllManualByDept(begin, end, this.txtDept.Text);
            }
            if (this.cbNo.Checked == true)
            {
                list = new ManualSignManager().GetAllManualByNo(begin, end, this.txtNo.Text);
            }
            if (this.cbName.Checked == true)
            {
                list = new ManualSignManager().GetAllManualByUserId(begin, end, this.txtName.Text);
            }
            this.GridView1.DataSource = list;
            this.GridView1.DataBind();
        }



    }
    private bool CheckEmpty()
    {
        if (this.txtBeginTime.Text == "")
        {
            Page.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script>alert('开始时间不能为空')</script>");
            return false;
        }
        if (this.txtEndTime.Text == "")
        {
            Page.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script>alert('结束时间不能为空')</script>");
            return false;
        }

        return true;
    }
    protected void cbDept_CheckedChanged(object sender, EventArgs e)
    {
        if (this.cbDept.Checked == true)
        {
            this.txtDept.Enabled = true;
        }
        else
        {
            this.txtDept.Enabled = false;
        }

    }
    protected void cbNo_CheckedChanged(object sender, EventArgs e)
    {
        if (this.cbNo.Checked == true)
        {
            this.txtNo.Enabled = true;
        }
        else
        {
            this.txtNo.Enabled = false;
        }
    }
    protected void cbName_CheckedChanged(object sender, EventArgs e)
    {
        if (this.cbName.Checked == true)
        {
            this.txtName.Enabled = true;
        }
        else
        {
            this.txtName.Enabled = false;
        }
    }
}